package com.industrial.premu.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.industrial.common.log.annotation.Log;
import com.industrial.common.log.enums.BusinessType;
import com.industrial.common.security.annotation.RequiresPermissions;
import com.industrial.premu.domain.PreMuDownshift;
import com.industrial.premu.service.IPreMuDownshiftService;
import com.industrial.common.core.web.controller.BaseController;
import com.industrial.common.core.web.domain.AjaxResult;
import com.industrial.common.core.utils.poi.ExcelUtil;
import com.industrial.common.core.web.page.TableDataInfo;

/**
 * 减档Controller
 * 
 * @author ZhouS
 * @date 2024-01-24
 */
@RestController
@RequestMapping("/downshift")
public class PreMuDownshiftController extends BaseController
{
    @Autowired
    private IPreMuDownshiftService preMuDownshiftService;

    /**
     * 查询减档列表
     */
    @RequiresPermissions("premu:downshift:list")
    @GetMapping("/list")
    public TableDataInfo list(PreMuDownshift preMuDownshift)
    {
        startPage();
        List<PreMuDownshift> list = preMuDownshiftService.selectPreMuDownshiftList(preMuDownshift);
        return getDataTable(list);
    }

    /**
     * 导出减档列表
     */
    @RequiresPermissions("premu:downshift:export")
    @Log(title = "减档", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PreMuDownshift preMuDownshift)
    {
        List<PreMuDownshift> list = preMuDownshiftService.selectPreMuDownshiftList(preMuDownshift);
        ExcelUtil<PreMuDownshift> util = new ExcelUtil<PreMuDownshift>(PreMuDownshift.class);
        util.exportExcel(response, list, "减档数据");
    }

    /**
     * 获取减档详细信息
     */
    @RequiresPermissions("premu:downshift:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(preMuDownshiftService.selectPreMuDownshiftById(id));
    }

    /**
     * 新增减档
     */
    @RequiresPermissions("premu:downshift:add")
    @Log(title = "减档", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PreMuDownshift preMuDownshift)
    {
        return toAjax(preMuDownshiftService.insertPreMuDownshift(preMuDownshift));
    }

    /**
     * 修改减档
     */
    @RequiresPermissions("premu:downshift:edit")
    @Log(title = "减档", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PreMuDownshift preMuDownshift)
    {
        return toAjax(preMuDownshiftService.updatePreMuDownshift(preMuDownshift));
    }

    /**
     * 删除减档
     */
    @RequiresPermissions("premu:downshift:remove")
    @Log(title = "减档", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(preMuDownshiftService.deletePreMuDownshiftByIds(ids));
    }
}
